// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Backup building / compositions in clipboard
// -----------------------------------------------

private [
	"_text",
	"_x",
	"_pos",
	"_absx",
	"_absy",
	"_dir",
	"_type",
	"_arrayof",
	"_var",
	"_marker",
	"_position",
	"_markersize",
	"_temp",
	"_xpos",
	"_ypos"
];

_marker = _this select 0;

_position = getMarkerPos _marker;
_markersize = (getMarkerSize _marker) select 0;

_arrayof = [];
_text = "";

_temp = nearestObjects [_position, ["All"], _markersize];
_xpos = _position select 0;
_ypos = _position select 1;

for "_i" from 0 to (count _temp) do {
	_x = _temp select _i;
	_pos = getPosATL _x;
	_absx = (_pos select 0) - _xpos;
	_absy = (_pos select 1) - _ypos;
	_dir = getDir _x;
	_type = typeOf _x;
	_arrayof = _arrayof + [[[_absx, _absy, _pos select 2], _dir, _type]];
	_var = [[_absx, _absy, _pos select 2], _dir, _type];

	switch (_i) do {
		case 0: {
			_text = _text + format ["[%1", _var];
		};

		case (count _temp): {
			_text = _text + format [",%1]", _var];
		};

		default {
			_text = _text + format [",%1", _var];
		};
	};
};

copyToClipboard _text;
hint format ["Backup %1 Buildings", count _temp];